using System;

namespace DA.AnimGraph {

    //public enum CurveType : byte {
    //    Constants,
    //}

    public enum CurveFusionType : byte {
        Weight,
    }

    public struct Curve {
        public CurveFusionType fusionType { get; private set; }
        AUID name;
        float value; // 目前先仅支持常量

        public Curve(AUID name, float value) {
            this.name = name;
            this.value = value;
            fusionType = CurveFusionType.Weight;
        }

        public CurveSample Sample(float time) {
            // 目前先仅支持常量
            return new CurveSample(name, value);
        }
    }

    // todo:曲线名也要包含在内,也许还要一个合并方式的枚举（按比例、按最大值等等）
    public struct CurveSample : IComparable<CurveSample> {
        //const byte ZeroMask = 0b00000000;
        public readonly AUID name;
        public float value;

        public CurveSample(AUID name, float value) {
            this.name = name;
            this.value = value;
        }

        public int CompareTo(CurveSample other) {
            if (name > other.name) {
                return 1;
            }
            if (name < other.name) {
                return -1;
            }
            return 0;
        }

        // -0为无效
        //public bool IsValid() {
        //    if (value != 0f) return true;
        //    byte[] bytes = BitConverter.GetBytes(value);
        //    bool isValid = true;
        //    for (int i = 0; i < bytes.Length; i++) {
        //        if ((bytes[i] | ZeroMask) != ZeroMask) {
        //            isValid = false;
        //            break;
        //        }
        //    }
        //    return isValid;
        //}
    }

}
